/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VentanaOperacionesNomina.java
 *
 * Created on 25/06/2010, 11:50:49 AM
 */

package CapaGrafica;
import CapaLogica.GestionResort;
import CapaDatos.Nomina;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import CapaPersistencia.ControladorNomina;

/**
 *
 * @author Maria
 */
public class VentanaOperacionesNomina extends javax.swing.JFrame {
private ControladorNomina control = new ControladorNomina();
    /** Creates new form VentanaOperacionesNomina */
    public VentanaOperacionesNomina() {
        initComponents();
        mostrarTabla();
        this.setSize(550,550);
    }
    private void mostrarTabla() {
        DefaultTableModel dm = new DefaultTableModel();
        dm.addColumn("Nombre");
        dm.addColumn("Apellido");
        dm.addColumn("Cedula");
        dm.addColumn("Sexo");
        dm.addColumn("Fecha Nacimiento");
        dm.addColumn("Estado Civil");
        dm.addColumn("Nacionalidad");
        ArrayList <Nomina> nominas = this.control.todaLaNomina();
        for (Nomina nomina : nominas) {
            Vector row = new Vector();

            row.add(nomina.getNombre());
            row.add(nomina.getApellido());
            row.add(nomina.getCedula());
            row.add(nomina.getSexo());
            row.add(nomina.getFechaNac());
            row.add(nomina.getEdoCivil());
            row.add(nomina.getNacionalidad());
            dm.addRow(row);
        }
        this.tablaNomina.setModel(dm);


    }

    private void mostrarNomina(String cedula) throws ParseException {
        Nomina NominaMostrar = this.control.buscarNomina(cedula);
        this.sCedula.setText(NominaMostrar.getCedula());
        this.sNombre.setText(NominaMostrar.getNombre());
        this.sApellido.setText(NominaMostrar.getApellido());
        this.sEdoCivil.setText(NominaMostrar.getEdoCivil());
        this.sNacionalidad.setText(NominaMostrar.getNacionalidad());
        this.sSexo.setText(NominaMostrar.getSexo());
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd-MM-yyyy");
        java.util.Date fecha = fechaFormato.parse(NominaMostrar.getFechaNac());
        this.sFecha.setDate(fecha);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jScrollPane2 = new javax.swing.JScrollPane();
        tablaNomina = new javax.swing.JTable();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        nApellido = new javax.swing.JTextField();
        jLapellido = new javax.swing.JLabel();
        nCedula = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        nEdoCivil = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        nFecha = new com.toedter.calendar.JDateChooser();
        nNacionalidad = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        nNombre = new javax.swing.JTextField();
        jLnombre = new javax.swing.JLabel();
        nSexo = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jBAgregar = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        sApellido = new javax.swing.JTextField();
        jLapellido1 = new javax.swing.JLabel();
        sCedula = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        sEdoCivil = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        sFecha = new com.toedter.calendar.JDateChooser();
        sNacionalidad = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        sNombre = new javax.swing.JTextField();
        jLnombre1 = new javax.swing.JLabel();
        sSexo = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jBActualizar = new javax.swing.JButton();
        jBBorrar = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JSeparator();
        jLabel16 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gestion de Nomina");
        setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        setLocationByPlatform(true);

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jScrollPane2.setName("jScrollPane2"); // NOI18N

        tablaNomina.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tablaNomina.setName("tablaNomina"); // NOI18N
        tablaNomina.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                tablaNominaMouseReleased(evt);
            }
        });
        tablaNomina.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                tablaNominaKeyReleased(evt);
            }
        });
        jScrollPane2.setViewportView(tablaNomina);

        jScrollPane1.setViewportView(jScrollPane2);

        jTabbedPane1.setName("jTabbedPane1"); // NOI18N

        jPanel1.setBackground(new java.awt.Color(0, 102, 153));
        jPanel1.setName("jPanel1"); // NOI18N

        nApellido.setName("nApellido"); // NOI18N

        jLapellido.setText("Apellido:");
        jLapellido.setName("jLapellido"); // NOI18N

        nCedula.setName("nCedula"); // NOI18N

        jLabel1.setText("Cedula:");
        jLabel1.setName("jLabel1"); // NOI18N

        nEdoCivil.setName("nEdoCivil"); // NOI18N
        nEdoCivil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                nEdoCivilActionPerformed(evt);
            }
        });

        jLabel2.setText("Estado Civil:");
        jLabel2.setName("jLabel2"); // NOI18N

        nFecha.setName("nFecha"); // NOI18N

        nNacionalidad.setName("nNacionalidad"); // NOI18N

        jLabel3.setText("Nacionalidad:");
        jLabel3.setName("jLabel3"); // NOI18N

        nNombre.setName("nNombre"); // NOI18N

        jLnombre.setText("Nombre:");
        jLnombre.setName("jLnombre"); // NOI18N

        nSexo.setName("nSexo"); // NOI18N

        jLabel7.setText("Sexo:");
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel9.setText("Fecha Nacimiento:");
        jLabel9.setName("jLabel9"); // NOI18N

        jBAgregar.setText("Agregar");
        jBAgregar.setName("jBAgregar"); // NOI18N
        jBAgregar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBAgregarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLnombre)
                            .addComponent(jLapellido)
                            .addComponent(jLabel1)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel9)
                                            .addComponent(jLabel3)
                                            .addComponent(jLabel7))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(nFecha, javax.swing.GroupLayout.PREFERRED_SIZE, 201, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(nSexo, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)
                                            .addComponent(nNacionalidad, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE)))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addGap(48, 48, 48)
                                        .addComponent(nEdoCivil, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGap(107, 107, 107)
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(nApellido, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                                            .addComponent(nNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE)
                                            .addComponent(nCedula, javax.swing.GroupLayout.DEFAULT_SIZE, 211, Short.MAX_VALUE))))
                                .addGap(16, 16, 16))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(134, 134, 134)
                        .addComponent(jBAgregar)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(30, 30, 30)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLnombre)
                    .addComponent(nNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLapellido)
                    .addComponent(nApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(nEdoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel9)
                    .addComponent(nFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addComponent(nNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(nSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addGap(30, 30, 30)
                .addComponent(jBAgregar)
                .addGap(79, 79, 79))
        );

        jTabbedPane1.addTab("Agregar", jPanel1);

        jPanel2.setBackground(new java.awt.Color(0, 102, 153));
        jPanel2.setName("jPanel2"); // NOI18N

        sApellido.setName("sApellido"); // NOI18N

        jLapellido1.setText("Apellido:");
        jLapellido1.setName("jLapellido1"); // NOI18N

        sCedula.setName("sCedula"); // NOI18N

        jLabel4.setText("Cedula:");
        jLabel4.setName("jLabel4"); // NOI18N

        sEdoCivil.setName("sEdoCivil"); // NOI18N
        sEdoCivil.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                sEdoCivilActionPerformed(evt);
            }
        });

        jLabel5.setText("Estado Civil:");
        jLabel5.setName("jLabel5"); // NOI18N

        sFecha.setName("sFecha"); // NOI18N

        sNacionalidad.setName("sNacionalidad"); // NOI18N

        jLabel6.setText("Nacionalidad:");
        jLabel6.setName("jLabel6"); // NOI18N

        sNombre.setName("sNombre"); // NOI18N

        jLnombre1.setText("Nombre:");
        jLnombre1.setName("jLnombre1"); // NOI18N

        sSexo.setName("sSexo"); // NOI18N

        jLabel8.setText("Sexo:");
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel10.setText("Fecha Nacimiento:");
        jLabel10.setName("jLabel10"); // NOI18N

        jBActualizar.setText("Actualizar");
        jBActualizar.setName("jBActualizar"); // NOI18N
        jBActualizar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBActualizarActionPerformed(evt);
            }
        });

        jBBorrar.setText("Borrar");
        jBBorrar.setName("jBBorrar"); // NOI18N
        jBBorrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBBorrarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jLabel5)
                    .addComponent(jLabel4)
                    .addComponent(jLapellido1)
                    .addComponent(jLnombre1)
                    .addComponent(jLabel6)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(sSexo, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sNacionalidad, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sApellido, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sCedula, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sEdoCivil, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sFecha, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addComponent(sNombre, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE))
                .addContainerGap())
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(jBActualizar)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 106, Short.MAX_VALUE)
                .addComponent(jBBorrar, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(34, 34, 34))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(48, 48, 48)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLnombre1)
                    .addComponent(sNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLapellido1)
                    .addComponent(sApellido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(sCedula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel5)
                    .addComponent(sEdoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel10)
                    .addComponent(sFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(sNacionalidad, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(sSexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBActualizar)
                    .addComponent(jBBorrar))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Actualizar o eliminar", jPanel2);

        jSeparator1.setName("jSeparator1"); // NOI18N

        jLabel16.setFont(new java.awt.Font("Trebuchet MS", 0, 36));
        jLabel16.setForeground(new java.awt.Color(0, 51, 204));
        jLabel16.setText("i-Resort.");
        jLabel16.setName("jLabel16"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 576, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 596, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 389, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 349, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(1, 1, 1)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 356, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(46, 46, 46))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void nEdoCivilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_nEdoCivilActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_nEdoCivilActionPerformed

    private void sEdoCivilActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sEdoCivilActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_sEdoCivilActionPerformed

    private void jBBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBBorrarActionPerformed
       boolean resultado = this.control.eliminarNomina(this.sCedula.getText());
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Empleado " + this.sNombre.getText() + " borrado con exito", "Borrado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jBBorrarActionPerformed

    private void jBAgregarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBAgregarActionPerformed
       boolean resultado = false;
        String cedula = this.nCedula.getText();
        String nombre = this.nNombre.getText();
        String apellido = this.nApellido.getText();
        String sexo = this.nSexo.getText();
        String nacionalidad = this.nNacionalidad.getText();
        String edoCivil= this.nEdoCivil.getText();
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date lafecha = this.nFecha.getDate();
        String fecha = fechaFormato.format(lafecha);
        if (GestionResort.getLasNominas().BuscarNominaPorCedula(cedula)== false) {
            resultado = this.control.nuevaNomina(cedula, nombre, apellido, sexo, nacionalidad, edoCivil, fecha);
            if (resultado) {
                JOptionPane.showMessageDialog(null, "Cliente " + nombre + " agregado con exito", "Agregado",
                        JOptionPane.INFORMATION_MESSAGE);
                this.mostrarTabla();
            } else {
                JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                        JOptionPane.ERROR_MESSAGE);
            }
        } else
            JOptionPane.showMessageDialog(null, "Operacion Fallida el Cliente con esta cedula se encuentra registrado ", "Error",
                    JOptionPane.ERROR_MESSAGE); // TODO add your handling code here:
    }//GEN-LAST:event_jBAgregarActionPerformed

    private void jBActualizarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBActualizarActionPerformed
      boolean resultado = false;
        String cedula = this.sCedula.getText();
        String nombre = this.sNombre.getText();
        String apellido = this.sApellido.getText();
        String sexo = this.sSexo.getText();
        String nacionalidad = this.sNacionalidad.getText();
        String edoCivil= this.sEdoCivil.getText();
        SimpleDateFormat fechaFormato = new SimpleDateFormat("dd/MM/yyyy");
        Date lafecha = this.sFecha.getDate();
        String fecha = fechaFormato.format(lafecha);
        resultado = this.control.actualizarNomina(cedula, nombre, apellido, sexo, nacionalidad, edoCivil, fecha);
        if (resultado) {
            JOptionPane.showMessageDialog(null, "Empleado " + nombre + " actualizado con exito", "Actualizado",
                    JOptionPane.INFORMATION_MESSAGE);
            this.mostrarTabla();
        } else {
            JOptionPane.showMessageDialog(null, "Operacion Fallida", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jBActualizarActionPerformed

    private void tablaNominaMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tablaNominaMouseReleased
        int row = this.tablaNomina.getSelectedRow();
        String cedula = (String) this.tablaNomina.getModel().getValueAt(row, 2);
        try {
            this.mostrarNomina(cedula);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesNomina.class.getName()).log(Level.SEVERE, null, ex);
        }// TODO add your handling code here:
    }//GEN-LAST:event_tablaNominaMouseReleased

    private void tablaNominaKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tablaNominaKeyReleased
       int row = this.tablaNomina.getSelectedRow();
        String cedula = (String) this.tablaNomina.getModel().getValueAt(row, 2);
        try {
            this.mostrarNomina(cedula);
        } catch (ParseException ex) {
            Logger.getLogger(VentanaOperacionesNomina.class.getName()).log(Level.SEVERE, null, ex);
        } // TODO add your handling code here:
    }//GEN-LAST:event_tablaNominaKeyReleased

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new VentanaOperacionesNomina().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBActualizar;
    private javax.swing.JButton jBAgregar;
    private javax.swing.JButton jBBorrar;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLapellido;
    private javax.swing.JLabel jLapellido1;
    private javax.swing.JLabel jLnombre;
    private javax.swing.JLabel jLnombre1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTextField nApellido;
    private javax.swing.JTextField nCedula;
    private javax.swing.JTextField nEdoCivil;
    private com.toedter.calendar.JDateChooser nFecha;
    private javax.swing.JTextField nNacionalidad;
    private javax.swing.JTextField nNombre;
    private javax.swing.JTextField nSexo;
    private javax.swing.JTextField sApellido;
    private javax.swing.JTextField sCedula;
    private javax.swing.JTextField sEdoCivil;
    private com.toedter.calendar.JDateChooser sFecha;
    private javax.swing.JTextField sNacionalidad;
    private javax.swing.JTextField sNombre;
    private javax.swing.JTextField sSexo;
    private javax.swing.JTable tablaNomina;
    // End of variables declaration//GEN-END:variables

}
